//
//  UIView_Extension.h
//  Simple_Imitated_QQ
//
//  Created by Zoo on 15-6-30.
//  Copyright (c) Zoo 2015年 Free. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (Category)

@property (nonatomic, assign) CGFloat   x;
@property (nonatomic, assign) CGFloat   y;
@property (nonatomic, assign) CGFloat   width;
@property (nonatomic, assign) CGFloat   height;
@property (nonatomic, assign) CGPoint   origin;
@property (nonatomic, assign) CGSize    size;
@property (nonatomic, assign) CGFloat   bottom;
@property (nonatomic, assign) CGFloat   right;
@property (nonatomic, assign) CGFloat   centerX;
@property (nonatomic, assign) CGFloat   centerY;
@property (nonatomic, strong, readonly) UIView *lastSubviewOnX;
@property (nonatomic, strong, readonly) UIView *lastSubviewOnY;

/**
 * @brief 移除此view上的所有子视图
 */
- (void)removeAllSubviews;
- (void)removeAllSubviewsFromTagRange:(NSRange)range;
- (void)removeAllSubviewsFromTag:(NSInteger)tag;
- (BOOL)containViewWithTag:(NSUInteger)tag;

//用来暂停layer上的动画
- (void)pauseLayer;

//恢复layer上的动画
- (void)resumeLayer;
/**
 *  设置view的阴影
 */
- (void)shadowWothOffset:(CGSize)offset radius:(CGFloat)radius opacity:(CGFloat)opacity color:(UIColor*)color;

- (BOOL)frameIsEqualTo:(CGRect)frame;
/**
 *  获取子视图
 */
- (UIView*)subviewWithTag:(NSInteger)tag;
/**
 * create view
 * @param frame view's frame
 * @param color view's background color
 * @param tag view's tag;
 */
+ (UIView*)createView:(CGRect)frame color:(UIColor*)color tag:(NSInteger)tag;
// remove subviews
+ (void)removeSubviews:(NSArray*)subviews;
+ (void)removeSubviews:(NSArray *)subviews forSubViewClass:(Class)subviewClass;
/*
 * show subviews
 */
- (void)printSubviews;
- (void)printAllSubviews;
/**
 * get view screen shot
 */
- (UIImage*)snapshotImage;
/**
 * select button
 */
- (void)selectedButton:(UIButton*)button;
/**
 * showing window
 */
+ (UIWindow*)showingWindow;

/**
 * enable all sub scrollview scrollable

 @param enable enable
 */
- (void)subScrollViewScrollsEnable:(BOOL)enable;

@end


@interface CALayer (Category)

@property (nonatomic, assign) CGFloat   x;
@property (nonatomic, assign) CGFloat   y;
@property (nonatomic, assign) CGFloat   width;
@property (nonatomic, assign) CGFloat   height;
@property (nonatomic, assign) CGPoint   origin;
@property (nonatomic, assign) CGSize    size;
@property (nonatomic, assign) CGFloat   bottom;
@property (nonatomic, assign) CGFloat   right;

- (void)transform:(NSString*)type subType:(NSString*)subType;
- (void)transform:(NSString*)type subType:(NSString*)subType interval:(NSTimeInterval)interval;
- (void)transform:(NSString *)type subType:(NSString *)subType complete:(dispatch_block_t)complete;

@end
